<template>
  <div ref="myChart" class="line-chart" />
</template>
<script >
import * as echarts from 'echarts'
export default {
  name: 'TriangleLine',
  props: ['rtChData'],
  data() {
    return {

    }
  },
  mounted() {
    this.chartRun()
  },
  methods: {
    chartRun() {
      const myChart = echarts.init(this.$refs.myChart)
      window.addEventListener('resize', myChart.resize)

      const that = this

      const option = {
        grid: {
          x: 0,
          y: 0,
          x2: 0,
          y2: 0
        },

        xAxis: {
          type: 'value',
          max: 1, // 最大值
          min: 0, // 最小值
          interval: 0.1, // 间隔
          splitLine: {
            // x网格样式
            show: false,
            lineStyle: {
              color: 'rgba(105, 160, 216, 0.24)',
              type: 'solid'
            }
          },
          axisLine: {
            show: false
          }
        },
        yAxis: {
          type: 'value',
          max: 1, // 最大值
          min: 0, // 最小值
          interval: 0.1, // 间隔
          splitLine: {
            // x网格样式
            show: false,
            lineStyle: {
              color: 'rgba(105, 160, 216, 0.24)',
              type: 'solid'
            }
          },
          axisLine: {
            show: false
          }
        },

        tooltip: {
          show: true,
          formatter: function(params) {
            return 'Rt: ' + params.data[0] + '<br>Ch: ' + params.data[1]
          },

          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: 'rgba(105, 160, 216, 0.8)'
            }

          }

        },

        series: [
          {
            data: that.RtChData,
            type: 'line',

            symbolSize: 20,
            itemStyle: {
              normal: {
                color: '#8cd5c2', // 改变折线点的颜色
                lineStyle: {
                  color: '#ffd200' // 改变折线颜色
                }
              }
            }
          }
        ]

      }
      myChart.setOption(option)
    }
  }
}
</script>
<style scoped>
.line-chart{
 width: 100%;
 height: 100%;
 }
</style>
